package com.hzqy.service.externalLink;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.externalLink.ExternalLinkDao;
import com.hzqy.web.vo.SysConfigVo;
import com.hzqy.web.vo.WlContentVo;

@Service
public class ExternalLinkServiceBean{
	protected final Logger LOG = LoggerFactory.getLogger(getClass());

	@Resource
	private ExternalLinkDao externalLinkDao;

	public SysConfigVo selectSysConfig(SysConfigVo sysConfigVo) {
		SysConfigVo sc = externalLinkDao.selectSysConfig(sysConfigVo);
		return sc;
	} 
	
	public WlContentVo selectWLContent(WlContentVo wlContentVo) {
		WlContentVo wlc = externalLinkDao.selectWLContent(wlContentVo);
		return wlc;
	} 
	
	public WlContentVo selectWLContentAvaliable(WlContentVo wlContentVo) {
		WlContentVo wlc = externalLinkDao.selectWLContent(wlContentVo);
		if(wlc!=null){
			SysConfigVo sysConfigVo = new SysConfigVo();
			sysConfigVo.setF_sc_key(wlContentVo.getSysConfigKey());
			wlc.setSysConfigVo(this.selectSysConfig(sysConfigVo));
			
			if(wlc.getF_wlc_status() == 1) {//外链必须为上线状态才可用
				if(wlc.getF_wlc_control() == 1) {//不受管控的可以直接使用
					return wlc;
				} else if(wlc.getF_wlc_control() == 0) {//受到管控 需要判断屏蔽开关是否开启
					if("1".equals(wlc.getSysConfigVo().getF_sc_value().trim())) {//开关为关闭状态，允许外链访问
						return wlc;
					}
				}
			}
			
		}
		return null;
	} 
	
}
